Use what you have learnt so far to build a page like this:
Questions for this Assignment
*ngFor="let author of authors"
// Generate component using Angular CLI
ng g c authors
Angular-CLI created a folder called "authors" and add 4 files inside the foler: a CSS file, a HTML file, a unit test file and a TypeScript file. It also registered the component in AppModule
.
ctrl + p
for navigating to different files in VS code// Generate service using Angular CLI
ng g s authors
app.module.ts
and register AuthorService as a provider:authors.service.ts
and add a method called getAuthors()
authors.component.ts
, inject the service into the contructor of the componentauthors.component.html
<h2>{{ authors.length }} Authors</h2>
<ul>
<li *ngFor="let author of authors">
{{ author }}
</li>
</ul>
authors.component.ts
, notice that the selector is named with prefix "app-" by the Angular CLI.app.component.html
to add the custom element tag<h1>Angular</h1>
<app-authors></app-authors>